<%-- 
    Document   : chitietSP
    Created on : 17-10-2011, 20:19:46
    Author     : VuTienIT
--%>

<%@page import="java.text.DecimalFormat"%>
<%@page import="java.util.ArrayList"%>
<%@page import="model.pojo.*"%>
<%@page import="model.dao.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
DecimalFormat df = new DecimalFormat("#,###");
request.removeAttribute("ThongBaoMua");
%>
<!DOCTYPE html>
<script language="Javascript" type="text/javascript" src="js/jquery_1_4_2.js"></script>
<script language="Javascript" type="text/javascript" src="js/kk_countdown_1_2_jquery_min.js"></script>
<style type="text/css">
		
            #odliczanie-a{
                font-size: 30px;
                font-family: Verdana, sans-serif;
            }

            #odliczanie-b{
                font-size: 18px;
                font-weight: normal;
                margin: 40px 0px;
            }
			
            .shadow{
                text-shadow: 1px 1px 1px #333;
            }

</style>
<script type="text/javascript">
            $(document).ready(function(){
                $("body").kkCountDown({
                    colorText:'#AA0000',
                    addClass : 'shadow'
                });
            });
</script>

<div id="content_middle">
<h3>Thông tin sản phẩm</h3>
<%
    PhieuPOJO p = (PhieuPOJO) request.getAttribute("Phieu");
    if(p != null)
    {
        NhaCungCapPOJO ncc = NhaCungCapDAO.getNhaCungCap(p.getMaNCC());
        long current_time = System.currentTimeMillis()/1000;
        long ketthuc = p.getKetThucKhuyenMai().getTime()/1000;
        long kq = ketthuc - current_time;  
%>
    <div class="detail_box">
    <img src="HinhAnh/HinhChinh/<%=p.getHinhChinh()%>" />
  <h3><%=p.getMoTa()%></h3>
    <div class="sidebar_box_content">       
    <p class="price">Giá ban đầu : <strong><%=df.format(p.getGiaGoc())%> VNĐ</strong></p>
    <p class="price">Giảm giá : <strong><%=p.getGiamGia()%>%</strong></p>
    <p class="price">Tiết kiệm :<strong> <%=df.format(p.getGiaGoc()-p.getGiaBan())%> VNĐ</strong></p>
    </div>        
    <br/>
    <div class="sidebar_box_content">
    <table border="0">
      <tr align="left">
        <td valign="middle">
            <p class="style1"><%=df.format(p.getGiaBan())%> VNĐ</p>                        
        </td>
        <td valign="middle">
           <%
           if(p.getSoLuongMua()>=p.getSoLuongQuyDinh()){
               request.setAttribute("ThongBaoMua", "Thông báo hết hàng, không thể mua được !");
           %>
           <img src="images/button-deal-notbuy.png" alt="" width="102" height="38" />
           <%
           }if(kq <=0){
               request.setAttribute("ThongBaoMua", "Đã hết hạn khuyến mãi !");
           %>
           <img src="images/button-deal-notbuy.png" alt="" width="102" height="38" />
           <%
            }else if(p.getSoLuongMua()<p.getSoLuongQuyDinh() && kq>0){
               request.setAttribute("ThongBaoMua", "Còn mua được !");
           %>
           <a href="GioHang?Page=Engage&action=Them&MaPhieu=<%=p.getMaPhieu()%>" class="detail"><img src="images/button-deal-buy_1.png" alt="" width="102" height="38" /></a>
           <%
             }
           %>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">Chỉ còn lại <span class="style2"><%=p.getSoLuongQuyDinh()-p.getSoLuongMua()%></span> cơ hội</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle" class="style2">
            <h4>
           <%
            if (request.getAttribute("ThongBaoMua") != null) {
                out.println(request.getAttribute("ThongBaoMua"));
            }
            %> 
            </h4>
        </td>
      </tr>
    </table>
    </div>
    <p>&nbsp;</p>
    <div class="sidebar_box_content">        
    <table width="100%" border="0">
        <tr>
          <td align="left" valign="middle"><strong>Thời gian còn lại</strong></td>
        </tr>
        <tr>
          <td align="left" valign="middle">
              <div id="odliczanie-a">
                <span time="<%=ketthuc%>" class="kkcount-down"></span>
            </div>
          </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
          <td align="left" valign="middle"><strong>Thời gian kết thúc</strong></td>
        </tr>
        <tr>
          <td align="left" valign="middle">
              <p class="ngayban"><%=p.getKetThucKhuyenMai()%></p>
          </td>
        </tr>
      </table>
            <p>&nbsp;</p>
    </div>
    <div class="sidebar_box_content">
      <table width="100%" border="0">
        <tr>
          <td align="left" valign="middle"><strong>Lưu ý</strong></td>
        </tr>
        <tr>
          <td align="left" valign="middle">
         <%=p.getLuuY()%></td>
        </tr>
        <tr>
          <td align="left" valign="middle">&nbsp;</td>
        </tr>
      </table>
    </div>
    <p>&nbsp;</p>
    <div class="sidebar_box_content">
      <table width="100%" border="0">
        <tr>
          <td align="left" valign="middle"><strong><%=ncc.getTenNCC()%></strong></td>
        </tr>
        <tr>
          <td align="left" valign="middle">
          <%=ncc.getMoTa()%>
          <br/>
          Điện thoại: <%=ncc.getDienThoai()%></td>
        </tr>
        <tr>
          <td align="left" valign="middle">
              <% if(ncc.getHinh()!=null || ncc.getHinh().trim()!=""){ %>
              <img src="HinhAnh/HinhNCC/<%=ncc.getHinh()%>"/>
              <% } %>
          </td>
        </tr>
      </table>
    </div>
    <p>&nbsp;</p>
    <div class="sidebar_box_content">
      <table width="100%" border="0">
        <tr>
          <td align="left" valign="middle"><strong>Thông tin khuyến mãi</strong></td>
        </tr>
        <tr>
          <td align="left" valign="middle">
              <%
            ArrayList<HinhCTPhieuPOJO> dsHinh = (ArrayList<HinhCTPhieuPOJO>) request.getAttribute("HinhCT");
            if(!dsHinh.isEmpty())
            {
                for(int i=0;i<dsHinh.size();i++)
                {
                    HinhCTPhieuPOJO gg = new HinhCTPhieuPOJO();
                    gg = dsHinh.get(i);
    
            %>
              <%=gg.getMoTa()%>
            <br/>
            <% 
            if(gg.getTenHinh()!=null || gg.getTenHinh().trim()!="" || gg.getTenHinh()!="")
            { 
            %>
                <img border="0" alt="" src="HinhAnh/HinhCTPhieu/<%=gg.getTenHinh()%>"/>
                <br/>
            <% 
            } 
            %>
            <%
               }
           }
            %>
          </td>
        </tr>
        <tr>
          <td align="left" valign="middle">&nbsp;</td>
        </tr>
      </table>
    </div>
    <p>&nbsp;</p>
</div>
<%
   }
%>

    <div class="cleaner"></div>
</div>